package utils;

import org.apache.commons.beanutils.BeanUtils;
import pojo.User;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

public class WebUtils {
    public static <T> T copyParamToBean(Map map, T bean){
        try {

            System.out.println("注入之前:"+bean);
            BeanUtils.populate(bean,map);
            System.out.println("注入之后:"+bean);
        } catch (Exception e) {
//            e.printStackTrace();
        }
        return bean;
    }

    public static  int parseInt(String strint,int defaultValue){
        try {
            return  Integer.parseInt(strint);
        } catch (Exception e) {
//            e.printStackTrace();
        }
        return defaultValue;
    }
}
